package com.wzd.imservice.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName: e_learning
 * @Package: com.wzd.imservice.enums
 * @ClassName: ChatTypeEnum
 * @Author: lofxve
 * @Description:
 * @Date: 2021/4/19 16:41
 * @Version: 1.0
 */

public enum ChatTypeEnum {
    FRIEND("friend", 0),

    GROUP("group", 1);

    private String name;
    private Integer key;

    ChatTypeEnum(String name, Integer key) {
        this.name = name;
        this.key = key;
    }

    public static String getNameByKey(int key) {
        for (ChatTypeEnum temp : ChatTypeEnum.values()) {
            if (temp.getKey().equals(key)) {
                return temp.getName();
            }
        }
        return "";
    }

    public static Map<String, Integer> getStringValueMap() {
        Map<String, Integer> res = new HashMap<>();
        for (ChatTypeEnum temp : ChatTypeEnum.values()) {
            res.put(temp.getName(), temp.getKey());
        }
        return res;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getKey() {
        return key;
    }

    public void setKey(Integer key) {
        this.key = key;
    }
}
